package Day06;

import java.util.Scanner;

public class MoneyGL {

    public void enterMainMenu(){
        boolean loopFlag = true;
        double balance = 10000;
        String details = "收  支\t账户金额\t收支金额\t说  明\r\n";
        Scanner sc = new Scanner(System.in);
        while(loopFlag){
            System.out.println("------------家庭收支记账软件------------");
            System.out.println();
            System.out.println("\t\t1 收支明细");
            System.out.println("\t\t2 登记收入");
            System.out.println("\t\t3 登记支出");
            System.out.println("\t\t4 退   出");
            System.out.println();
            System.out.print("\t请选择(1-4):");
            int no = sc.nextInt();
            while (no<1||no>4){
                System.out.println("您输入的编号有误，请重新输入(1-4)");
                no = sc.nextInt();
            }
            switch (no){
                case 1:
                    System.out.println();
                    System.out.println("------------当前收支明细记录------------");
                    System.out.println(details);
                    System.out.println("--------------------------------------");
                    break;
                case 2:
                    System.out.print("本次收入金额:");
                    double income = sc.nextDouble();
                    System.out.print("本次收入说明:");
                    String inStr  =sc.next();
                    balance+=income;
                    details = details+"收  入\t"+balance+"\t"+income+"\t"+inStr+"\r\n";
                    break;
                case 3:
                    System.out.print("本次支出金额:");
                    double outcome = sc.nextDouble();
                    System.out.print("本次支出说明:");
                    String outStr  =sc.next();
                    balance-=outcome;
                    details = details+"支  出\t"+balance+"\t"+outcome+"\t"+outStr+"\r\n";
                    break;
                case 4:
                    System.out.print("确认是否退出(Y/N):");
                    String str  =sc.next();
                    if (str.equals("Y")||str.equals("y")){
                        loopFlag=false;
                    }
                    break;
            }
        }
        System.out.println("感谢使用本系统!");
        sc.close();
    }


    public static void main(String[] args) {
        MoneyGL ml = new MoneyGL();
        ml.enterMainMenu();
    }
}
